<link rel="stylesheet" href="__CDN__/assets/element-ui-2.15.14/css/index.css">
<link rel="stylesheet" href="__CDN__/assets/css/vvv.css">
<style>
    .el-form-item__label {
        width: 120px !important;
    }

    .el-tag + .el-tag {
        margin-left: 10px;
    }

    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }

    input[type="file"] {
        display: none !important;
    }

    .el-form-item__error {
        margin-left: 30px;
    }

    .search-select .el-input--suffix .el-input__inner {
        width: 130px;
    }

    .status-bg {
        color: #fff;
        padding: 4px;
        width: 80px;
        text-align: center;
        margin: 0 auto;
        border-radius: 4px;
    }

    .user-box {
        display: flex;
        align-items: center;
    }

    .user-box .a-avatar img {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 10px;
    }
</style>
<div id="vue" v-cloak>
    <div class="screen-container">
        <div class="screen-container-show">
            <el-button style="margin-top: 14px;" size="small" @click="refreshPage" icon="el-icon-refresh" circle
                       type="primary"></el-button>
            <div class="screen-container-left display-flex">
                <div class="datetime">
                    <el-date-picker
                            v-model="search.startTime"
                            type="datetime"
                            placeholder="选择起始时间">
                    </el-date-picker>
                </div>
                <div class="datetime">
                    <el-date-picker
                            v-model="search.endTime"
                            type="datetime"
                            placeholder="选择结束时间">
                    </el-date-picker>
                </div>
            </div>
            <div class="search-select screen-container-right display-flex keyword">
                <el-select v-model="search.status" @clear="handleClearSelect('status')" clearable placeholder="Vip名称">
                    <el-option
                            v-for="item in vipList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </div>
            <div class="search-select screen-container-right display-flex keyword v-key">
                <el-input @clear="handleClearSearchInp" clearable v-model="search.keyword" placeholder="请输入您要搜索的内容">
                    <el-select v-model="search.type" slot="prepend" placeholder="请选择">
                        <el-option v-for="(item, index) in searchOpt" :label="item.value"
                                   :value="item.id">
                        </el-option>
                    </el-select>
                    <el-button slot="append" @click="searchData" icon="el-icon-search"></el-button>
                </el-input>
            </div>
            <div class="search-select screen-container-right display-flex keyword">
                <el-button @click="openAddDialog('add', '')" size="small" type="primary" plain icon="el-icon-plus">添加
                </el-button>
                <el-button @click="del" size="small" type="danger" plain icon="el-icon-delete">删除
                </el-button>
            </div>
        </div>
    </div>
    <div class="vue-table background-white color-666">
        <el-table :data="tableData" border highlight-current-row v-loading="listLoading"
                  @sort-change="sortChange" :element-loading-text="loadingText"
                  @selection-change="handleSelectionChange" style="width: 100%">
            <el-table-column type="selection" width="60" align="center"></el-table-column>
            <el-table-column prop="order_no" width="200" label="订单号" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="vip.name" width="150" label="Vip名称" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="pay_price" width="130" label="付款金额" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="nickname" width="130" label="用户昵称" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="avatar" label="照片" width="80" align="center">
                <template scope="scope">
                    <a :href="scope.row.avatar" target="_blank">
                        <img :src="scope.row.avatar"
                             style="border-radius: 10px;width: 48px;height: 48px;padding: 5px">
                    </a>
                </template>
            </el-table-column>
            <el-table-column prop="mobile" width="150" label="手机号码" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column align="center" prop="status" width="110" label="时长类型">
                <template scope="scope">
                    <el-button v-if="scope.row.status == 1" size="mini" type="success" plain icon="el-icon-check">已付款</el-button>
                    <el-button v-if="scope.row.status == 2" size="mini" type="primary" plain icon="el-icon-date">待付款</el-button>
                </template>
            </el-table-column>
            <el-table-column prop="pay_time" width="160" :formatter="dateFormat" label="付款时间" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="expires_time" width="160" :formatter="dateFormat" label="到期时间" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="create_time" width="160" :formatter="dateFormat" label="创建时间" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column align="center" width="130" fixed="right" label="操作">
                <template scope="scope">
                    <button @click="dell(scope.row.id)" type="button"
                            class="el-button el-button--danger el-button--small"><i
                            class="el-icon-delete"></i><span>删除</span></button>
                </template>
            </el-table-column>
        </el-table>
        <div class="layout-pagination">
            <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="totalCount">
            </el-pagination>
        </div>
    </div>

    <!-- 添加编辑 -->
    <div class="users-dialog">
        <el-dialog
                :close-on-click-modal="false"
                :title="title"
                :visible.sync="addDialog"
                width="50%"
        >
            <div class="form">
                <el-form ref="form" :rules="rules" :model="formData" label-width="90px">
                    <el-form-item label="Vip：" prop="vid">
                        <el-select v-model="formData.vid" style="width: 330px;" clearable placeholder="请您选择Vip">
                            <el-option
                                    v-for="item in vipList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="用户：" prop="user_id">
                        <div class="a-box">
                            <div v-if="formData.user_id" style="margin-bottom: 15px;" class="user">
                                <div class="user-box">
                                    <div class="a-avatar">
                                        <img :src="user.avatar" alt="头像">
                                    </div>
                                    <div class="a-info">
                                        <div class="a-username">
                                            用户名：{{user.nickname}}
                                        </div>
                                        <div class="u-mobile">
                                            手机号码：{{user.mobile}}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div style="margin-left: 30px;" class="user-btn">
                                <el-button @click="openUserDialog" icon="el-icon-user-solid" size="small" type="primary" plain>
                                    选择用户
                                </el-button>
                            </div>
                        </div>
                    </el-form-item>
                    <el-form-item label="时长：" prop="num">
                        <el-input-number v-model="formData.num" :min="1" :step="1"></el-input-number>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDialog = false" size="small" icon="el-icon-switch-button">取 消</el-button>
                <el-button type="primary" size="small" @click="submit" icon="el-icon-position">提 交</el-button>
            </span>
        </el-dialog>
    </div>
</div>

<script src="__CDN__/assets/element-ui-2.15.14/js/vue.js"></script>
<script src="__CDN__/assets/element-ui-2.15.14/js/index.js"></script>
<script src="__CDN__/assets/tool/libs/moment.js"></script>
<script src="__CDN__/assets/js/jquery-2.1.1.min.js"></script>